<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>冒泡排序</title>
	</head>

	<body>
		<script>
			var arr = [80, 70, 5, 400, 60, 4400, 34, 3];
			for(var i = 0; i < arr.length - 1; i++) {
				for(var j = 0; j < arr.length - 1; j++) {
					if(arr[j] > arr[j + 1]) {
						var temp = arr[j];
						arr[j] = arr[j + 1];
						arr[j + 1] = temp;
					}
				}
			}

			console.log(arr);

			//第一遍分解
			/* if(arr[0] > arr[0+1]){
			     var temp = arr[0];
			     arr[0] = arr[0+1];
			     arr[0+1] = temp;
			 }
			 if(arr[1] > arr[1+1]){
			     var temp = arr[1];
			     arr[1] = arr[1+1];
			     arr[1+1] = temp;
			 }
			 if(arr[2] > arr[2+1]){
			     var temp = arr[2];
			     arr[2] = arr[2+1];
			     arr[2+1] = temp;
			 }
			 if(arr[3] > arr[3+1]){
			     var temp = arr[3];
			     arr[3] = arr[3+1];
			     arr[3+1] = temp;
			 }
			 if(arr[4] > arr[4+1]){
			     var temp = arr[4];
			     arr[4] = arr[4+1];
			     arr[4+1] = temp;
			 }*/
		</script>
	</body>

</html>